package com.gao;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan(basePackages = "com.gao.dao")
@EnableEurekaClient   //在服务启动后  自动注册到eureka中
//@EnableDiscoveryClient //服务发现

@EnableCircuitBreaker
public class ProviderHystrixDept8081 {
    public static void main(String[] args) {
        SpringApplication.run(ProviderHystrixDept8081.class, args);
        System.out.println("启动成功 hystrix");
    }


    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet() {
        ServletRegistrationBean regist = new ServletRegistrationBean();
        regist.setServlet(new HystrixMetricsStreamServlet());
        regist.addUrlMappings("/hystrix.stream");
        return regist;
    }
}
 
